#include "release-valve.h"

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
ReleaseValve::ReleaseValve(QObject* parent) : Device(parent)
  , Py(0.0)
  , Qrv(0.0)
  , release (false)
  , K1(1.0)
{

}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
ReleaseValve::~ReleaseValve()
{

}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void ReleaseValve::ode_system(const state_vector_t& Y, state_vector_t& dYdt, double t)
{
    Q_UNUSED(Y)
    Q_UNUSED(dYdt)
    Q_UNUSED(t)
}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void ReleaseValve::load_config(CfgReader& cfg)
{
    QString secName = "Device";
    cfg.getDouble(secName, "K1", K1);
}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void ReleaseValve::preStep(state_vector_t& Y, double t)
{
    Q_UNUSED(Y)
    Q_UNUSED(t)

    Qrv = - Py * K1 * static_cast<double>(release);
}
